package com.ditri.blog.service.impl;

import com.ditri.blog.dao.UserStartCommentDao;
import com.ditri.blog.entity.UserStartComment;
import com.ditri.blog.service.UserStartCommentService;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;

/**
 * (UserStartComment)表服务实现类
 *
 * @author makejava
 * @since 2020-07-29 18:18:32
 */
@Service("userStartCommentService")
public class UserStartCommentServiceImpl implements UserStartCommentService {
    @Resource
    private UserStartCommentDao userStartCommentDao;

    /**
     * 通过ID查询单条数据
     *
     * @param id 主键
     * @return 实例对象
     */
    @Override
    public UserStartComment queryById(Long id) {
        return this.userStartCommentDao.queryById(id);
    }

    /**
     * 查询多条数据
     *
     * @param offset 查询起始位置
     * @param limit  查询条数
     * @return 对象列表
     */
    @Override
    public List<UserStartComment> queryAllByLimit(int offset, int limit) {
        return this.userStartCommentDao.queryAllByLimit(offset, limit);
    }

    /**
     * 新增数据
     *
     * @param userStartComment 实例对象
     * @return 实例对象
     */
    @Override
    public UserStartComment insert(UserStartComment userStartComment) {
        this.userStartCommentDao.insert(userStartComment);
        return userStartComment;
    }

    /**
     * 修改数据
     *
     * @param userStartComment 实例对象
     * @return 实例对象
     */
    @Override
    public UserStartComment update(UserStartComment userStartComment) {
        this.userStartCommentDao.update(userStartComment);
        return this.queryById(userStartComment.getId());
    }

    /**
     * 通过主键删除数据
     *
     * @param id 主键
     * @return 是否成功
     */
    @Override
    public boolean deleteById(Long id) {
        return this.userStartCommentDao.deleteById(id) > 0;
    }
}